<%--
  Created by IntelliJ IDEA.
  User: 92329
  Date: 2018/4/8
  Time: 14:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="common.jspf"%>
<html>
<head>
    <title>预览</title>
    <script>
        var articleID;
        $(function () {
            var obj=jQuery.parseJSON('${json}');
            articleID=obj.id;
            var title=obj.title;
            $("#title h1").html(title);
            var author=obj.author;
            $("#author").html(author);
            var datetimestr=obj.datetimestr;
            $("#datetime").html(datetimestr);
            var content=htmldecode(obj.content);
            $("#content").html(content);
            var docname=obj.docName;
            var docurl=obj.docUrl;
            if(docname!=null){
                $("#docs").show();
                $("#docs a").attr('href',docurl).attr('download',docname).text(docname);
            }
            var state=obj.state;
            $("#subingButton").hide();
            if(state==0){
                $("#oksubButton").hide()
            }else (
                $("#subButton").hide()

            )

        });
        function closePage() {
            window.opener = null;
            window.open('', '_self');
            window.close();
        }
        function toSub() {
            $("#subingButton").show();
            $.post("${hkxyPath}/${type}/publish-only",{id:articleID},function () {
                //$("#subButton").removeClass("btn-primary").addClass("disabled btn-default").text("已发布");
                $("#subingButton").hide();
                $("#subButton").hide();
                $("#oksubButton").show();
            },null);
        }
    </script>
</head>
<body>
    <div style="width: 600px;margin: auto;padding-top: 20px">
        <div id="title" class="padding-b-5">
            <h1 class="text-center"></h1>
        </div>
        <div id="info" class="text-right padding-b-5">
            <span id="datetime"></span>
            <span id="author"></span>
        </div>
        <div id="content" class="padding-b-5 padding-t-5">

        </div>
        <div id="docs" class="padding-b-5" hidden>
            附件：<a href="" download=""></a>
        </div>
        <div id="btn" class="text-right padding-b-5 padding-t-5">
            <button id="subButton" type="button" class="btn btn-primary" onclick="toSub()">发布</button>
            <button id="subingButton" type="button" class="btn btn-default disabled">发布中...</button>
            <button id="oksubButton" type="button" class="btn btn-default disabled">已发布</button>

            <button type="button" class="btn btn-default" onclick="closePage()">关闭</button>
        </div>
    </div>
</body>
</html>
